#pragma once
#include <QDialog>
#include <QLineEdit>
#include <QLabel>
#include <QShowEvent>
#include <QCloseEvent>
#include <QTimer>
#include <QPushButton>
#include <QCheckBox>
#include <QHBoxLayout>
#include <QStackedWidget>
#include "Keyboard/KeyboardManager.h"

using namespace AeaQt;

class InfoDialog : public QDialog
{
    Q_OBJECT
public:
    explicit InfoDialog(QWidget *parent = nullptr);
    void updateLockButtons();

    QPushButton *loadLockBtn;

    QString getBrandCode() const { return m_brandCode; }
    QString getStoreName() const { return m_storeName; }
    QString getZone() const { return m_zone; }
    QString getSnCode() const { return m_snCode; }
    QString getDeviceType() const { return m_deviceType; }
    bool isAuthEnabled() const { return m_authEnabled; }
    bool isCardEnabled() const { return m_cardEnabled; }
    bool isPalmEnabled() const { return m_palmEnabled; }
    bool isFaceEnabled() const { return m_faceEnabled; }

signals:
    void configChanged();

protected:
    void showEvent(QShowEvent *event) override;
    void closeEvent(QCloseEvent *event) override;

private slots:
    void loadConfig();
    void saveConfig();
    void updateClassVariables();
    // void onWifiBtnClicked();
    void onLoadLockBtnClicked();

private:
    void setupUI();
    void setupDeviceConfigPage();
    void setupOfflinePage();
    void setupConnections();

    QLineEdit *brandEdit;
    QLineEdit *storeEdit;
    QLineEdit *zoneEdit;
    QLineEdit *snEdit;
    QLineEdit *typeEdit;
    QLabel *resultLabel;
    Keyboard *keyboard;
    QPushButton *wifiBtn;

    QCheckBox *authCheck;
    QCheckBox *cardCheck;
    QCheckBox *palmCheck;
    QCheckBox *faceCheck;

    QString m_brandCode;
    QString m_storeName;
    QString m_zone;
    QString m_snCode;
    QString m_deviceType;
    bool m_authEnabled;
    bool m_cardEnabled;
    bool m_palmEnabled;
    bool m_faceEnabled;

    QHBoxLayout *lockAreaLayout;
    QStackedWidget *stackedWidget;
    QWidget *deviceConfigWidget;
    QWidget *offlineWidget;
    QPushButton *deviceConfigBtn;
    QPushButton *offlineOpenBtn;
    QPushButton *okBtn;
    QPushButton *backBtn;
    QPushButton *updateBtn;
    QPushButton *openAllLocksBtn;
};